home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
view JSON data
|
view as text
This file was processed as: LaTeX Document
(document/latex).
You can browse this item here: librotor.tex
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| LaTeX Document (document/latex)
| magic
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| LaTeX document text
| default
| |
99%
| file
| LaTeX document, ASCII text, with CR line terminators
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/281 LaTeX (Subdocument)
| default
| |
100%
| detectItEasy
| Format: plain text[CR]
| default (weak)
|
|
id metadata |
---|
key | value |
---|
macFileType | [TEXT] |
macFileCreator | [R*ch] |
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 73 65 63 74 69 6f 6e | 7b 42 75 69 6c 74 2d 69 |\section|{Built-i|
|00000010| 6e 20 6d 6f 64 75 6c 65 | 20 5c 73 65 63 74 63 6f |n module| \sectco|
|00000020| 64 65 7b 72 6f 74 6f 72 | 7d 7d 0d 5c 62 69 6d 6f |de{rotor|}}.\bimo|
|00000030| 64 69 6e 64 65 78 7b 72 | 6f 74 6f 72 7d 0d 0d 54 |dindex{r|otor}..T|
|00000040| 68 69 73 20 6d 6f 64 75 | 6c 65 20 69 6d 70 6c 65 |his modu|le imple|
|00000050| 6d 65 6e 74 73 20 61 20 | 72 6f 74 6f 72 2d 62 61 |ments a |rotor-ba|
|00000060| 73 65 64 20 65 6e 63 72 | 79 70 74 69 6f 6e 20 61 |sed encr|yption a|
|00000070| 6c 67 6f 72 69 74 68 6d | 2c 20 63 6f 6e 74 72 69 |lgorithm|, contri|
|00000080| 62 75 74 65 64 20 62 79 | 0d 4c 61 6e 63 65 20 45 |buted by|.Lance E|
|00000090| 6c 6c 69 6e 67 68 6f 75 | 73 65 2e 20 20 54 68 65 |llinghou|se. The|
|000000a0| 20 64 65 73 69 67 6e 20 | 69 73 20 64 65 72 69 76 | design |is deriv|
|000000b0| 65 64 20 66 72 6f 6d 20 | 74 68 65 20 45 6e 69 67 |ed from |the Enig|
|000000c0| 6d 61 20 64 65 76 69 63 | 65 2c 20 61 20 6d 61 63 |ma devic|e, a mac|
|000000d0| 68 69 6e 65 0d 75 73 65 | 64 20 64 75 72 69 6e 67 |hine.use|d during|
|000000e0| 20 57 6f 72 6c 64 20 57 | 61 72 20 49 49 20 74 6f | World W|ar II to|
|000000f0| 20 65 6e 63 69 70 68 65 | 72 20 6d 65 73 73 61 67 | enciphe|r messag|
|00000100| 65 73 2e 20 20 41 20 72 | 6f 74 6f 72 20 69 73 20 |es. A r|otor is |
|00000110| 73 69 6d 70 6c 79 20 61 | 0d 70 65 72 6d 75 74 61 |simply a|.permuta|
|00000120| 74 69 6f 6e 2e 20 20 46 | 6f 72 20 65 78 61 6d 70 |tion. F|or examp|
|00000130| 6c 65 2c 20 69 66 20 74 | 68 65 20 63 68 61 72 61 |le, if t|he chara|
|00000140| 63 74 65 72 20 60 41 27 | 20 69 73 20 74 68 65 20 |cter `A'| is the |
|00000150| 6f 72 69 67 69 6e 20 6f | 66 20 74 68 65 20 72 6f |origin o|f the ro|
|00000160| 74 6f 72 2c 0d 74 68 65 | 6e 20 61 20 67 69 76 65 |tor,.the|n a give|
|00000170| 6e 20 72 6f 74 6f 72 20 | 6d 69 67 68 74 20 6d 61 |n rotor |might ma|
|00000180| 70 20 60 41 27 20 74 6f | 20 60 4c 27 2c 20 60 42 |p `A' to| `L', `B|
|00000190| 27 20 74 6f 20 60 5a 27 | 2c 20 60 43 27 20 74 6f |' to `Z'|, `C' to|
|000001a0| 20 60 47 27 2c 20 61 6e | 64 20 73 6f 20 6f 6e 2e | `G', an|d so on.|
|000001b0| 0d 54 6f 20 65 6e 63 72 | 79 70 74 2c 20 77 65 20 |.To encr|ypt, we |
|000001c0| 63 68 6f 6f 73 65 20 73 | 65 76 65 72 61 6c 20 64 |choose s|everal d|
|000001d0| 69 66 66 65 72 65 6e 74 | 20 72 6f 74 6f 72 73 2c |ifferent| rotors,|
|000001e0| 20 61 6e 64 20 73 65 74 | 20 74 68 65 20 6f 72 69 | and set| the ori|
|000001f0| 67 69 6e 73 20 6f 66 20 | 74 68 65 0d 72 6f 74 6f |gins of |the.roto|
|00000200| 72 73 20 74 6f 20 6b 6e | 6f 77 6e 20 70 6f 73 69 |rs to kn|own posi|
|00000210| 74 69 6f 6e 73 3b 20 74 | 68 65 69 72 20 69 6e 69 |tions; t|heir ini|
|00000220| 74 69 61 6c 20 70 6f 73 | 69 74 69 6f 6e 20 69 73 |tial pos|ition is|
|00000230| 20 74 68 65 20 63 69 70 | 68 65 72 69 6e 67 20 6b | the cip|hering k|
|00000240| 65 79 2e 20 20 54 6f 0d | 65 6e 63 69 70 68 65 72 |ey. To.|encipher|
|00000250| 20 61 20 63 68 61 72 61 | 63 74 65 72 2c 20 77 65 | a chara|cter, we|
|00000260| 20 70 65 72 6d 75 74 65 | 20 74 68 65 20 6f 72 69 | permute| the ori|
|00000270| 67 69 6e 61 6c 20 63 68 | 61 72 61 63 74 65 72 20 |ginal ch|aracter |
|00000280| 62 79 20 74 68 65 20 66 | 69 72 73 74 20 72 6f 74 |by the f|irst rot|
|00000290| 6f 72 2c 0d 61 6e 64 20 | 74 68 65 6e 20 61 70 70 |or,.and |then app|
|000002a0| 6c 79 20 74 68 65 20 73 | 65 63 6f 6e 64 20 72 6f |ly the s|econd ro|
|000002b0| 74 6f 72 27 73 20 70 65 | 72 6d 75 74 61 74 69 6f |tor's pe|rmutatio|
|000002c0| 6e 20 74 6f 20 74 68 65 | 20 72 65 73 75 6c 74 2e |n to the| result.|
|000002d0| 20 57 65 20 63 6f 6e 74 | 69 6e 75 65 0d 75 6e 74 | We cont|inue.unt|
|000002e0| 69 6c 20 77 65 27 76 65 | 20 61 70 70 6c 69 65 64 |il we've| applied|
|000002f0| 20 61 6c 6c 20 74 68 65 | 20 72 6f 74 6f 72 73 3b | all the| rotors;|
|00000300| 20 74 68 65 20 72 65 73 | 75 6c 74 69 6e 67 20 63 | the res|ulting c|
|00000310| 68 61 72 61 63 74 65 72 | 20 69 73 20 6f 75 72 0d |haracter| is our.|
|00000320| 63 69 70 68 65 72 74 65 | 78 74 2e 20 20 57 65 20 |cipherte|xt. We |
|00000330| 74 68 65 6e 20 63 68 61 | 6e 67 65 20 74 68 65 20 |then cha|nge the |
|00000340| 6f 72 69 67 69 6e 20 6f | 66 20 74 68 65 20 66 69 |origin o|f the fi|
|00000350| 6e 61 6c 20 72 6f 74 6f | 72 20 62 79 20 6f 6e 65 |nal roto|r by one|
|00000360| 20 70 6f 73 69 74 69 6f | 6e 2c 0d 66 72 6f 6d 20 | positio|n,.from |
|00000370| 60 41 27 20 74 6f 20 60 | 42 27 3b 20 69 66 20 74 |`A' to `|B'; if t|
|00000380| 68 65 20 66 69 6e 61 6c | 20 72 6f 74 6f 72 20 68 |he final| rotor h|
|00000390| 61 73 20 6d 61 64 65 20 | 61 20 63 6f 6d 70 6c 65 |as made |a comple|
|000003a0| 74 65 20 72 65 76 6f 6c | 75 74 69 6f 6e 2c 20 74 |te revol|ution, t|
|000003b0| 68 65 6e 20 77 65 0d 72 | 6f 74 61 74 65 20 74 68 |hen we.r|otate th|
|000003c0| 65 20 6e 65 78 74 2d 74 | 6f 2d 6c 61 73 74 20 72 |e next-t|o-last r|
|000003d0| 6f 74 6f 72 20 62 79 20 | 6f 6e 65 20 70 6f 73 69 |otor by |one posi|
|000003e0| 74 69 6f 6e 2c 20 61 6e | 64 20 61 70 70 6c 79 20 |tion, an|d apply |
|000003f0| 74 68 65 20 73 61 6d 65 | 20 70 72 6f 63 65 64 75 |the same| procedu|
|00000400| 72 65 0d 72 65 63 75 72 | 73 69 76 65 6c 79 2e 20 |re.recur|sively. |
|00000410| 20 49 6e 20 6f 74 68 65 | 72 20 77 6f 72 64 73 2c | In othe|r words,|
|00000420| 20 61 66 74 65 72 20 65 | 6e 63 69 70 68 65 72 69 | after e|ncipheri|
|00000430| 6e 67 20 6f 6e 65 20 63 | 68 61 72 61 63 74 65 72 |ng one c|haracter|
|00000440| 2c 20 77 65 20 61 64 76 | 61 6e 63 65 0d 74 68 65 |, we adv|ance.the|
|00000450| 20 72 6f 74 6f 72 73 20 | 69 6e 20 74 68 65 20 73 | rotors |in the s|
|00000460| 61 6d 65 20 66 61 73 68 | 69 6f 6e 20 61 73 20 61 |ame fash|ion as a|
|00000470| 20 63 61 72 27 73 20 6f | 64 6f 6d 65 74 65 72 2e | car's o|dometer.|
|00000480| 20 44 65 63 6f 64 69 6e | 67 20 77 6f 72 6b 73 20 | Decodin|g works |
|00000490| 69 6e 20 74 68 65 0d 73 | 61 6d 65 20 77 61 79 2c |in the.s|ame way,|
|000004a0| 20 65 78 63 65 70 74 20 | 77 65 20 72 65 76 65 72 | except |we rever|
|000004b0| 73 65 20 74 68 65 20 70 | 65 72 6d 75 74 61 74 69 |se the p|ermutati|
|000004c0| 6f 6e 73 20 61 6e 64 20 | 61 70 70 6c 79 20 74 68 |ons and |apply th|
|000004d0| 65 6d 20 69 6e 20 74 68 | 65 20 6f 70 70 6f 73 69 |em in th|e opposi|
|000004e0| 74 65 0d 6f 72 64 65 72 | 2e 0d 5c 69 6e 64 65 78 |te.order|..\index|
|000004f0| 7b 45 6c 6c 69 6e 67 68 | 6f 75 73 65 2c 20 4c 61 |{Ellingh|ouse, La|
|00000500| 6e 63 65 7d 0d 5c 69 6e | 64 65 78 69 69 7b 45 6e |nce}.\in|dexii{En|
|00000510| 69 67 6d 61 7d 7b 63 69 | 70 68 65 72 7d 0d 0d 54 |igma}{ci|pher}..T|
|00000520| 68 65 20 61 76 61 69 6c | 61 62 6c 65 20 66 75 6e |he avail|able fun|
|00000530| 63 74 69 6f 6e 73 20 69 | 6e 20 74 68 69 73 20 6d |ctions i|n this m|
|00000540| 6f 64 75 6c 65 20 61 72 | 65 3a 0d 0d 5c 72 65 6e |odule ar|e:..\ren|
|00000550| 65 77 63 6f 6d 6d 61 6e | 64 7b 5c 69 6e 64 65 78 |ewcomman|d{\index|
|00000560| 73 75 62 69 74 65 6d 7d | 7b 28 69 6e 20 6d 6f 64 |subitem}|{(in mod|
|00000570| 75 6c 65 20 72 6f 74 6f | 72 29 7d 0d 5c 62 65 67 |ule roto|r)}.\beg|
|00000580| 69 6e 7b 66 75 6e 63 64 | 65 73 63 7d 7b 6e 65 77 |in{funcd|esc}{new|
|00000590| 72 6f 74 6f 72 7d 7b 6b | 65 79 5c 6f 70 74 69 6f |rotor}{k|ey\optio|
|000005a0| 6e 61 6c 7b 5c 2c 20 6e | 75 6d 72 6f 74 6f 72 73 |nal{\, n|umrotors|
|000005b0| 7d 7d 0d 52 65 74 75 72 | 6e 73 20 61 20 72 6f 74 |}}.Retur|ns a rot|
|000005c0| 6f 72 20 6f 62 6a 65 63 | 74 2e 20 5c 76 61 72 7b |or objec|t. \var{|
|000005d0| 6b 65 79 7d 20 69 73 20 | 61 20 73 74 72 69 6e 67 |key} is |a string|
|000005e0| 20 63 6f 6e 74 61 69 6e | 69 6e 67 20 74 68 65 20 | contain|ing the |
|000005f0| 65 6e 63 72 79 70 74 69 | 6f 6e 20 6b 65 79 0d 66 |encrypti|on key.f|
|00000600| 6f 72 20 74 68 65 20 6f | 62 6a 65 63 74 3b 20 69 |or the o|bject; i|
|00000610| 74 20 63 61 6e 20 63 6f | 6e 74 61 69 6e 20 61 72 |t can co|ntain ar|
|00000620| 62 69 74 72 61 72 79 20 | 62 69 6e 61 72 79 20 64 |bitrary |binary d|
|00000630| 61 74 61 2e 20 54 68 65 | 20 6b 65 79 20 77 69 6c |ata. The| key wil|
|00000640| 6c 20 62 65 20 75 73 65 | 64 0d 74 6f 20 72 61 6e |l be use|d.to ran|
|00000650| 64 6f 6d 6c 79 20 67 65 | 6e 65 72 61 74 65 20 74 |domly ge|nerate t|
|00000660| 68 65 20 72 6f 74 6f 72 | 20 70 65 72 6d 75 74 61 |he rotor| permuta|
|00000670| 74 69 6f 6e 73 20 61 6e | 64 20 74 68 65 69 72 20 |tions an|d their |
|00000680| 69 6e 69 74 69 61 6c 20 | 70 6f 73 69 74 69 6f 6e |initial |position|
|00000690| 73 2e 0d 5c 76 61 72 7b | 6e 75 6d 72 6f 74 6f 72 |s..\var{|numrotor|
|000006a0| 73 7d 20 69 73 20 74 68 | 65 20 6e 75 6d 62 65 72 |s} is th|e number|
|000006b0| 20 6f 66 20 72 6f 74 6f | 72 20 70 65 72 6d 75 74 | of roto|r permut|
|000006c0| 61 74 69 6f 6e 73 20 69 | 6e 20 74 68 65 20 72 65 |ations i|n the re|
|000006d0| 74 75 72 6e 65 64 20 6f | 62 6a 65 63 74 3b 0d 69 |turned o|bject;.i|
|000006e0| 66 20 69 74 20 69 73 20 | 6f 6d 69 74 74 65 64 2c |f it is |omitted,|
|000006f0| 20 61 20 64 65 66 61 75 | 6c 74 20 76 61 6c 75 65 | a defau|lt value|
|00000700| 20 6f 66 20 36 20 77 69 | 6c 6c 20 62 65 20 75 73 | of 6 wi|ll be us|
|00000710| 65 64 2e 0d 5c 65 6e 64 | 7b 66 75 6e 63 64 65 73 |ed..\end|{funcdes|
|00000720| 63 7d 0d 0d 52 6f 74 6f | 72 20 6f 62 6a 65 63 74 |c}..Roto|r object|
|00000730| 73 20 68 61 76 65 20 74 | 68 65 20 66 6f 6c 6c 6f |s have t|he follo|
|00000740| 77 69 6e 67 20 6d 65 74 | 68 6f 64 73 3a 0d 0d 5c |wing met|hods:..\|
|00000750| 72 65 6e 65 77 63 6f 6d | 6d 61 6e 64 7b 5c 69 6e |renewcom|mand{\in|
|00000760| 64 65 78 73 75 62 69 74 | 65 6d 7d 7b 28 72 6f 74 |dexsubit|em}{(rot|
|00000770| 6f 72 20 6d 65 74 68 6f | 64 29 7d 0d 5c 62 65 67 |or metho|d)}.\beg|
|00000780| 69 6e 7b 66 75 6e 63 64 | 65 73 63 7d 7b 73 65 74 |in{funcd|esc}{set|
|00000790| 6b 65 79 7d 7b 7d 0d 52 | 65 73 65 74 73 20 74 68 |key}{}.R|esets th|
|000007a0| 65 20 72 6f 74 6f 72 20 | 74 6f 20 69 74 73 20 69 |e rotor |to its i|
|000007b0| 6e 69 74 69 61 6c 20 73 | 74 61 74 65 2e 0d 5c 65 |nitial s|tate..\e|
|000007c0| 6e 64 7b 66 75 6e 63 64 | 65 73 63 7d 0d 0d 5c 62 |nd{funcd|esc}..\b|
|000007d0| 65 67 69 6e 7b 66 75 6e | 63 64 65 73 63 7d 7b 65 |egin{fun|cdesc}{e|
|000007e0| 6e 63 72 79 70 74 7d 7b | 70 6c 61 69 6e 74 65 78 |ncrypt}{|plaintex|
|000007f0| 74 7d 0d 52 65 73 65 74 | 73 20 74 68 65 20 72 6f |t}.Reset|s the ro|
|00000800| 74 6f 72 20 6f 62 6a 65 | 63 74 20 74 6f 20 69 74 |tor obje|ct to it|
|00000810| 73 20 69 6e 69 74 69 61 | 6c 20 73 74 61 74 65 20 |s initia|l state |
|00000820| 61 6e 64 20 65 6e 63 72 | 79 70 74 73 20 5c 76 61 |and encr|ypts \va|
|00000830| 72 7b 70 6c 61 69 6e 74 | 65 78 74 7d 2c 0d 72 65 |r{plaint|ext},.re|
|00000840| 74 75 72 6e 69 6e 67 20 | 61 20 73 74 72 69 6e 67 |turning |a string|
|00000850| 20 63 6f 6e 74 61 69 6e | 69 6e 67 20 74 68 65 20 | contain|ing the |
|00000860| 63 69 70 68 65 72 74 65 | 78 74 2e 20 20 54 68 65 |cipherte|xt. The|
|00000870| 20 63 69 70 68 65 72 74 | 65 78 74 20 69 73 20 61 | ciphert|ext is a|
|00000880| 6c 77 61 79 73 20 74 68 | 65 0d 73 61 6d 65 20 6c |lways th|e.same l|
|00000890| 65 6e 67 74 68 20 61 73 | 20 74 68 65 20 6f 72 69 |ength as| the ori|
|000008a0| 67 69 6e 61 6c 20 70 6c | 61 69 6e 74 65 78 74 2e |ginal pl|aintext.|
|000008b0| 0d 5c 65 6e 64 7b 66 75 | 6e 63 64 65 73 63 7d 0d |.\end{fu|ncdesc}.|
|000008c0| 0d 5c 62 65 67 69 6e 7b | 66 75 6e 63 64 65 73 63 |.\begin{|funcdesc|
|000008d0| 7d 7b 65 6e 63 72 79 70 | 74 6d 6f 72 65 7d 7b 70 |}{encryp|tmore}{p|
|000008e0| 6c 61 69 6e 74 65 78 74 | 7d 0d 45 6e 63 72 79 70 |laintext|}.Encryp|
|000008f0| 74 73 20 5c 76 61 72 7b | 70 6c 61 69 6e 74 65 78 |ts \var{|plaintex|
|00000900| 74 7d 20 77 69 74 68 6f | 75 74 20 72 65 73 65 74 |t} witho|ut reset|
|00000910| 74 69 6e 67 20 74 68 65 | 20 72 6f 74 6f 72 20 6f |ting the| rotor o|
|00000920| 62 6a 65 63 74 2c 20 61 | 6e 64 20 72 65 74 75 72 |bject, a|nd retur|
|00000930| 6e 73 20 61 0d 73 74 72 | 69 6e 67 20 63 6f 6e 74 |ns a.str|ing cont|
|00000940| 61 69 6e 69 6e 67 20 74 | 68 65 20 63 69 70 68 65 |aining t|he ciphe|
|00000950| 72 74 65 78 74 2e 0d 5c | 65 6e 64 7b 66 75 6e 63 |rtext..\|end{func|
|00000960| 64 65 73 63 7d 0d 0d 5c | 62 65 67 69 6e 7b 66 75 |desc}..\|begin{fu|
|00000970| 6e 63 64 65 73 63 7d 7b | 64 65 63 72 79 70 74 7d |ncdesc}{|decrypt}|
|00000980| 7b 63 69 70 68 65 72 74 | 65 78 74 7d 0d 52 65 73 |{ciphert|ext}.Res|
|00000990| 65 74 73 20 74 68 65 20 | 72 6f 74 6f 72 20 6f 62 |ets the |rotor ob|
|000009a0| 6a 65 63 74 20 74 6f 20 | 69 74 73 20 69 6e 69 74 |ject to |its init|
|000009b0| 69 61 6c 20 73 74 61 74 | 65 20 61 6e 64 20 64 65 |ial stat|e and de|
|000009c0| 63 72 79 70 74 73 20 5c | 76 61 72 7b 63 69 70 68 |crypts \|var{ciph|
|000009d0| 65 72 74 65 78 74 7d 2c | 0d 72 65 74 75 72 6e 69 |ertext},|.returni|
|000009e0| 6e 67 20 61 20 73 74 72 | 69 6e 67 20 63 6f 6e 74 |ng a str|ing cont|
|000009f0| 61 69 6e 69 6e 67 20 74 | 68 65 20 63 69 70 68 65 |aining t|he ciphe|
|00000a00| 72 74 65 78 74 2e 20 20 | 54 68 65 20 70 6c 61 69 |rtext. |The plai|
|00000a10| 6e 74 65 78 74 20 73 74 | 72 69 6e 67 20 77 69 6c |ntext st|ring wil|
|00000a20| 6c 0d 61 6c 77 61 79 73 | 20 62 65 20 74 68 65 20 |l.always| be the |
|00000a30| 73 61 6d 65 20 6c 65 6e | 67 74 68 20 61 73 20 74 |same len|gth as t|
|00000a40| 68 65 20 63 69 70 68 65 | 72 74 65 78 74 2e 0d 5c |he ciphe|rtext..\|
|00000a50| 65 6e 64 7b 66 75 6e 63 | 64 65 73 63 7d 0d 0d 5c |end{func|desc}..\|
|00000a60| 62 65 67 69 6e 7b 66 75 | 6e 63 64 65 73 63 7d 7b |begin{fu|ncdesc}{|
|00000a70| 64 65 63 72 79 70 74 6d | 6f 72 65 7d 7b 63 69 70 |decryptm|ore}{cip|
|00000a80| 68 65 72 74 65 78 74 7d | 0d 44 65 63 72 79 70 74 |hertext}|.Decrypt|
|00000a90| 73 20 5c 76 61 72 7b 63 | 69 70 68 65 72 74 65 78 |s \var{c|iphertex|
|00000aa0| 74 7d 20 77 69 74 68 6f | 75 74 20 72 65 73 65 74 |t} witho|ut reset|
|00000ab0| 74 69 6e 67 20 74 68 65 | 20 72 6f 74 6f 72 20 6f |ting the| rotor o|
|00000ac0| 62 6a 65 63 74 2c 20 61 | 6e 64 20 72 65 74 75 72 |bject, a|nd retur|
|00000ad0| 6e 73 20 61 0d 73 74 72 | 69 6e 67 20 63 6f 6e 74 |ns a.str|ing cont|
|00000ae0| 61 69 6e 69 6e 67 20 74 | 68 65 20 63 69 70 68 65 |aining t|he ciphe|
|00000af0| 72 74 65 78 74 2e 0d 5c | 65 6e 64 7b 66 75 6e 63 |rtext..\|end{func|
|00000b00| 64 65 73 63 7d 0d 0d 41 | 6e 20 65 78 61 6d 70 6c |desc}..A|n exampl|
|00000b10| 65 20 75 73 61 67 65 3a | 0d 5c 62 63 6f 64 65 5c |e usage:|.\bcode\|
|00000b20| 62 65 67 69 6e 7b 76 65 | 72 62 61 74 69 6d 7d 0d |begin{ve|rbatim}.|
|00000b30| 3e 3e 3e 20 69 6d 70 6f | 72 74 20 72 6f 74 6f 72 |>>> impo|rt rotor|
|00000b40| 0d 3e 3e 3e 20 72 74 20 | 3d 20 72 6f 74 6f 72 2e |.>>> rt |= rotor.|
|00000b50| 6e 65 77 72 6f 74 6f 72 | 28 27 6b 65 79 27 2c 20 |newrotor|('key', |
|00000b60| 31 32 29 0d 3e 3e 3e 20 | 72 74 2e 65 6e 63 72 79 |12).>>> |rt.encry|
|00000b70| 70 74 28 27 62 61 72 27 | 29 0d 27 5c 32 35 33 34 |pt('bar'|).'\2534|
|00000b80| 5c 33 36 33 27 0d 3e 3e | 3e 20 72 74 2e 65 6e 63 |\363'.>>|> rt.enc|
|00000b90| 72 79 70 74 6d 6f 72 65 | 28 27 62 61 72 27 29 0d |ryptmore|('bar').|
|00000ba0| 27 5c 33 35 37 5c 33 37 | 35 24 27 0d 3e 3e 3e 20 |'\357\37|5$'.>>> |
|00000bb0| 72 74 2e 65 6e 63 72 79 | 70 74 28 27 62 61 72 27 |rt.encry|pt('bar'|
|00000bc0| 29 0d 27 5c 32 35 33 34 | 5c 33 36 33 27 0d 3e 3e |).'\2534|\363'.>>|
|00000bd0| 3e 20 72 74 2e 64 65 63 | 72 79 70 74 28 27 5c 32 |> rt.dec|rypt('\2|
|00000be0| 35 33 34 5c 33 36 33 27 | 29 0d 27 62 61 72 27 0d |534\363'|).'bar'.|
|00000bf0| 3e 3e 3e 20 72 74 2e 64 | 65 63 72 79 70 74 6d 6f |>>> rt.d|ecryptmo|
|00000c00| 72 65 28 27 5c 33 35 37 | 5c 33 37 35 24 27 29 0d |re('\357|\375$').|
|00000c10| 27 62 61 72 27 0d 3e 3e | 3e 20 72 74 2e 64 65 63 |'bar'.>>|> rt.dec|
|00000c20| 72 79 70 74 28 27 5c 33 | 35 37 5c 33 37 35 24 27 |rypt('\3|57\375$'|
|00000c30| 29 0d 27 6c 28 5c 33 31 | 35 27 0d 3e 3e 3e 20 64 |).'l(\31|5'.>>> d|
|00000c40| 65 6c 20 72 74 0d 5c 65 | 6e 64 7b 76 65 72 62 61 |el rt.\e|nd{verba|
|00000c50| 74 69 6d 7d 5c 65 63 6f | 64 65 0d 0d 54 68 65 20 |tim}\eco|de..The |
|00000c60| 6d 6f 64 75 6c 65 27 73 | 20 63 6f 64 65 20 69 73 |module's| code is|
|00000c70| 20 6e 6f 74 20 61 6e 20 | 65 78 61 63 74 20 73 69 | not an |exact si|
|00000c80| 6d 75 6c 61 74 69 6f 6e | 20 6f 66 20 74 68 65 20 |mulation| of the |
|00000c90| 6f 72 69 67 69 6e 61 6c | 20 45 6e 69 67 6d 61 20 |original| Enigma |
|00000ca0| 64 65 76 69 63 65 3b 0d | 69 74 20 69 6d 70 6c 65 |device;.|it imple|
|00000cb0| 6d 65 6e 74 73 20 74 68 | 65 20 72 6f 74 6f 72 20 |ments th|e rotor |
|00000cc0| 65 6e 63 72 79 70 74 69 | 6f 6e 20 73 63 68 65 6d |encrypti|on schem|
|00000cd0| 65 20 64 69 66 66 65 72 | 65 6e 74 6c 79 20 66 72 |e differ|ently fr|
|00000ce0| 6f 6d 20 74 68 65 20 6f | 72 69 67 69 6e 61 6c 2e |om the o|riginal.|
|00000cf0| 20 54 68 65 0d 6d 6f 73 | 74 20 69 6d 70 6f 72 74 | The.mos|t import|
|00000d00| 61 6e 74 20 64 69 66 66 | 65 72 65 6e 63 65 20 69 |ant diff|erence i|
|00000d10| 73 20 74 68 61 74 20 69 | 6e 20 74 68 65 20 6f 72 |s that i|n the or|
|00000d20| 69 67 69 6e 61 6c 20 45 | 6e 69 67 6d 61 2c 20 74 |iginal E|nigma, t|
|00000d30| 68 65 72 65 20 77 65 72 | 65 20 6f 6e 6c 79 20 35 |here wer|e only 5|
|00000d40| 0d 6f 72 20 36 20 64 69 | 66 66 65 72 65 6e 74 20 |.or 6 di|fferent |
|00000d50| 72 6f 74 6f 72 73 20 69 | 6e 20 65 78 69 73 74 65 |rotors i|n existe|
|00000d60| 6e 63 65 2c 20 61 6e 64 | 20 74 68 65 79 20 77 65 |nce, and| they we|
|00000d70| 72 65 20 61 70 70 6c 69 | 65 64 20 74 77 69 63 65 |re appli|ed twice|
|00000d80| 20 74 6f 20 65 61 63 68 | 0d 63 68 61 72 61 63 74 | to each|.charact|
|00000d90| 65 72 3b 20 74 68 65 20 | 63 69 70 68 65 72 20 6b |er; the |cipher k|
|00000da0| 65 79 20 77 61 73 20 74 | 68 65 20 6f 72 64 65 72 |ey was t|he order|
|00000db0| 20 69 6e 20 77 68 69 63 | 68 20 74 68 65 79 20 77 | in whic|h they w|
|00000dc0| 65 72 65 20 70 6c 61 63 | 65 64 20 69 6e 20 74 68 |ere plac|ed in th|
|00000dd0| 65 0d 6d 61 63 68 69 6e | 65 2e 20 20 54 68 65 20 |e.machin|e. The |
|00000de0| 50 79 74 68 6f 6e 20 72 | 6f 74 6f 72 20 6d 6f 64 |Python r|otor mod|
|00000df0| 75 6c 65 20 75 73 65 73 | 20 74 68 65 20 73 75 70 |ule uses| the sup|
|00000e00| 70 6c 69 65 64 20 6b 65 | 79 20 74 6f 20 69 6e 69 |plied ke|y to ini|
|00000e10| 74 69 61 6c 69 7a 65 20 | 61 0d 72 61 6e 64 6f 6d |tialize |a.random|
|00000e20| 20 6e 75 6d 62 65 72 20 | 67 65 6e 65 72 61 74 6f | number |generato|
|00000e30| 72 3b 20 74 68 65 20 72 | 6f 74 6f 72 20 70 65 72 |r; the r|otor per|
|00000e40| 6d 75 74 61 74 69 6f 6e | 73 20 61 6e 64 20 74 68 |mutation|s and th|
|00000e50| 65 69 72 20 69 6e 69 74 | 69 61 6c 20 70 6f 73 69 |eir init|ial posi|
|00000e60| 74 69 6f 6e 73 0d 61 72 | 65 20 74 68 65 6e 20 72 |tions.ar|e then r|
|00000e70| 61 6e 64 6f 6d 6c 79 20 | 67 65 6e 65 72 61 74 65 |andomly |generate|
|00000e80| 64 2e 20 20 54 68 65 20 | 6f 72 69 67 69 6e 61 6c |d. The |original|
|00000e90| 20 64 65 76 69 63 65 20 | 6f 6e 6c 79 20 65 6e 63 | device |only enc|
|00000ea0| 69 70 68 65 72 65 64 20 | 74 68 65 0d 6c 65 74 74 |iphered |the.lett|
|00000eb0| 65 72 73 20 6f 66 20 74 | 68 65 20 61 6c 70 68 61 |ers of t|he alpha|
|00000ec0| 62 65 74 2c 20 77 68 69 | 6c 65 20 74 68 69 73 20 |bet, whi|le this |
|00000ed0| 6d 6f 64 75 6c 65 20 63 | 61 6e 20 68 61 6e 64 6c |module c|an handl|
|00000ee0| 65 20 61 6e 79 20 38 2d | 62 69 74 20 62 69 6e 61 |e any 8-|bit bina|
|00000ef0| 72 79 20 64 61 74 61 3b | 0d 69 74 20 61 6c 73 6f |ry data;|.it also|
|00000f00| 20 70 72 6f 64 75 63 65 | 73 20 62 69 6e 61 72 79 | produce|s binary|
|00000f10| 20 6f 75 74 70 75 74 2e | 20 20 54 68 69 73 20 6d | output.| This m|
|00000f20| 6f 64 75 6c 65 20 63 61 | 6e 20 61 6c 73 6f 20 6f |odule ca|n also o|
|00000f30| 70 65 72 61 74 65 20 77 | 69 74 68 20 61 6e 0d 61 |perate w|ith an.a|
|00000f40| 72 62 69 74 72 61 72 79 | 20 6e 75 6d 62 65 72 20 |rbitrary| number |
|00000f50| 6f 66 20 72 6f 74 6f 72 | 73 2e 0d 0d 54 68 65 20 |of rotor|s...The |
|00000f60| 6f 72 69 67 69 6e 61 6c | 20 45 6e 69 67 6d 61 20 |original| Enigma |
|00000f70| 63 69 70 68 65 72 20 77 | 61 73 20 62 72 6f 6b 65 |cipher w|as broke|
|00000f80| 6e 20 69 6e 20 31 39 34 | 34 2e 20 25 20 58 58 58 |n in 194|4. % XXX|
|00000f90| 3a 20 49 73 20 74 68 69 | 73 20 72 69 67 68 74 3f |: Is thi|s right?|
|00000fa0| 0d 54 68 65 20 76 65 72 | 73 69 6f 6e 20 69 6d 70 |.The ver|sion imp|
|00000fb0| 6c 65 6d 65 6e 74 65 64 | 20 68 65 72 65 20 69 73 |lemented| here is|
|00000fc0| 20 70 72 6f 62 61 62 6c | 79 20 61 20 67 6f 6f 64 | probabl|y a good|
|00000fd0| 20 64 65 61 6c 20 6d 6f | 72 65 20 64 69 66 66 69 | deal mo|re diffi|
|00000fe0| 63 75 6c 74 20 74 6f 20 | 63 72 61 63 6b 0d 28 65 |cult to |crack.(e|
|00000ff0| 73 70 65 63 69 61 6c 6c | 79 20 69 66 20 79 6f 75 |speciall|y if you|
|00001000| 20 75 73 65 20 6d 61 6e | 79 20 72 6f 74 6f 72 73 | use man|y rotors|
|00001010| 29 2c 20 62 75 74 20 69 | 74 20 77 6f 6e 27 74 20 |), but i|t won't |
|00001020| 62 65 20 69 6d 70 6f 73 | 73 69 62 6c 65 20 66 6f |be impos|sible fo|
|00001030| 72 0d 61 20 74 72 75 6c | 79 20 73 6b 69 6c 66 75 |r.a trul|y skilfu|
|00001040| 6c 20 61 6e 64 20 64 65 | 74 65 72 6d 69 6e 65 64 |l and de|termined|
|00001050| 20 61 74 74 61 63 6b 65 | 72 20 74 6f 20 62 72 65 | attacke|r to bre|
|00001060| 61 6b 20 74 68 65 20 63 | 69 70 68 65 72 2e 20 20 |ak the c|ipher. |
|00001070| 53 6f 20 69 66 20 79 6f | 75 20 77 61 6e 74 0d 74 |So if yo|u want.t|
|00001080| 6f 20 6b 65 65 70 20 74 | 68 65 20 4e 53 41 20 6f |o keep t|he NSA o|
|00001090| 75 74 20 6f 66 20 79 6f | 75 72 20 66 69 6c 65 73 |ut of yo|ur files|
|000010a0| 2c 20 74 68 69 73 20 72 | 6f 74 6f 72 20 63 69 70 |, this r|otor cip|
|000010b0| 68 65 72 20 6d 61 79 20 | 77 65 6c 6c 20 62 65 20 |her may |well be |
|000010c0| 75 6e 73 61 66 65 2c 20 | 62 75 74 0d 66 6f 72 20 |unsafe, |but.for |
|000010d0| 64 69 73 63 6f 75 72 61 | 67 69 6e 67 20 63 61 73 |discoura|ging cas|
|000010e0| 75 61 6c 20 73 6e 6f 6f | 70 69 6e 67 20 74 68 72 |ual snoo|ping thr|
|000010f0| 6f 75 67 68 20 79 6f 75 | 72 20 66 69 6c 65 73 2c |ough you|r files,|
|00001100| 20 69 74 20 77 69 6c 6c | 20 70 72 6f 62 61 62 6c | it will| probabl|
|00001110| 79 20 62 65 0d 6a 75 73 | 74 20 66 69 6e 65 2c 20 |y be.jus|t fine, |
|00001120| 61 6e 64 20 6d 61 79 20 | 62 65 20 73 6f 6d 65 77 |and may |be somew|
|00001130| 68 61 74 20 73 61 66 65 | 72 20 74 68 61 6e 20 75 |hat safe|r than u|
|00001140| 73 69 6e 67 20 74 68 65 | 20 55 6e 69 78 20 5c 66 |sing the| Unix \f|
|00001150| 69 6c 65 7b 63 72 79 70 | 74 7d 0d 63 6f 6d 6d 61 |ile{cryp|t}.comma|
|00001160| 6e 64 2e 0d 5c 69 6e 64 | 65 78 7b 4e 61 74 69 6f |nd..\ind|ex{Natio|
|00001170| 6e 61 6c 20 53 65 63 75 | 72 69 74 79 20 41 67 65 |nal Secu|rity Age|
|00001180| 6e 63 79 7d 5c 69 6e 64 | 65 78 7b 63 72 79 70 74 |ncy}\ind|ex{crypt|
|00001190| 28 31 29 7d 0d 25 20 58 | 58 58 20 48 6f 77 20 77 |(1)}.% X|XX How w|
|000011a0| 65 72 65 20 55 6e 69 78 | 20 63 6f 6d 6d 61 6e 64 |ere Unix| command|
|000011b0| 73 20 72 65 70 72 65 73 | 65 6e 74 65 64 20 69 6e |s repres|ented in|
|000011c0| 20 74 68 65 20 64 6f 63 | 73 3f 0d 0d | the doc|s?.. |
+--------+-------------------------+-------------------------+--------+--------+